#pragma once

#ifndef __CORE_StrId_H__
#define __CORE_StrId_H__

#include "FLOW_core/namespace.h"
#include "FLOW_core/hash_funcs.h"

namespace CORE
{
	/*!
	 * \brief This class represents a string used as identifier, the string is hashed for fast comparison.
	 *
	 * This class represents a string used as identifier, the string is hashed for fast comparison. All the
	 * real strings are stored in the CStrIdMgr to avoid storing the same string repeteadly.
	 */
	class CStrId
	{
	private:
		//============================== DATA MEMBERS =========================

		//! Hash value of the string stored
		hashid_t	m_hash_id;

		//! Boolean that tells if the hash value is valid or not
		bool_t		m_b_is_valid;

	public:
		//================================ METHODS ============================

		//! Default constructor
		CStrId( );

		//! Destructor
		~CStrId( );

		//! Copy constructor
		CStrId( const CStrId& ar_strid );

		//! Assignment operator
		CStrId& operator = ( const CStrId& ar_strid );

		//! Constructor from string
		CStrId( const char* apsz_string_id );

		//! Constructor from hash value
		CStrId( hashid_t& ar_hashid );

		//! Replace value with string
		void Set( const char_t* apsz_string_id );

		//! Replace value with hash value
		void Set( hashid_t& ar_hashid );

		//! Reset the StrId
		void Reset( void );

		//! Returns the hash value of the stored string if any
		hashid_t Hash( void ) const;

		//! Returns the string, if not valid returns NULL
		const char_t* String( void );
		const char_t* c_str( void );

		//! Compares two StrIds for equality, this is very fast because is done using the hash value
		bool_t operator == ( const CStrId& ar_strid ) const;
		bool_t Equals( const CStrId& ar_strid ) const;
	};
} //namespace CORE

#endif